<?php 
/**
 * This file is part of DomFg.
 * 
 * DomFg is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * DomFg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DomFg.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @link http://inditel.ee/
 * @copyright 2007-2009 Inditel Meedia OÜ
 * @author Oliver Leisalu <oliver@inditel.ee>
 */

/**
* @author Oliver Leisalu, Inditel Meedia
* @package DomFg
*/
abstract class DomFgComponent {
	
	protected $id;
	
	/**
	* @var String
	*/
	protected $template;
	/**
	* @var String
	*/
	protected $style;
	
	/**
	* Used by Table layout
	* @var Int
	*/
	protected $colspan = 1;
	/**
	* Used by Table layout
	* @var Int
	*/
	protected $rowspan = 1;
	/**
	* Used by Table layout to apply special style to cell
	* @var String
	*/
	protected $cellStyle = '';
	
	/**
	* In table layout sets item position in table.
	* In absolute layout sets item position.
	* @var Int
	*/
	protected $x;
	/**
	* In table layout sets item position in table.
	* In absolute layout sets item position.
	* @var Int
	*/
	protected $y;
	
	/**
	* If under TabPanel then if component is treated as tab content or not!
	* @var Boolean
	*/
	protected $isTab;
	
	private $renderer;
	

	
	final public function template( $template ) {
		$this->template = $template;
		return $this;
	}
	
	final public function id( $id ) {
		$this->id = $id;
		return $this;
	}
	
	final public function style( $style ) {
		$this->style = $style;
		return $this;
	}
	
	final public function cellStyle( $cellStyle ) {
		$this->cellStyle = $cellStyle;
		return $this;
	}
	
	final public function isTab( $isTab ) {
		$this->isTab = $isTab;
		return $this;
	}
	
	public function colspan( $colspan ) {
		$this->colspan = (int)$colspan;
		return $this;
	}
	
	public function rowspan( $rowspan ) {
		$this->rowspan = (int)$rowspan;
		return $this;
	}
	
	public function x( $x ) {
		$this->x = $x;
		return $this;
	}
	
	public function y( $y ) {
		$this->y = $y;
		return $this;
	}
	
	final public function __get( $var ) {
		return $this->$var;
	}
	
	public function getRenderer() {
		if( $this->renderer === NULL ) {
			$this->renderer = new DomSmarty();
			$this->renderer->template_dir = DomFg::getTemplatePath();
			$this->renderer->assign('templateUrl', DomFg::getTemplateUrl() );
		}
		return $this->renderer;
	}
	
	abstract public function render();
}
?>